p = {'(':')', '{':'}', '[':']', '<':'>'}
p1 = {'(', ')', '[', ']', '{', '}', '<', '>'}


def check(s):
    a = []
    b = 1
    l = list()
    for j in s:
        if j in p1:
            l.append(j)

    for i in l:
        if i in p:
            a.append(i)
        elif i == p[a.pop()] and not a and b == len(l):
            return True
        b += 1
    return False


print(check(input('Введите скобочную последовательность: ')))